#import "ImageCell.h"
#import <Foundation/Foundation.h>
#import <Masonry.h>
@implementation ImageCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

// 初始化
 - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
     self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
     if (self) {
         //设置圆角
         self.layer.cornerRadius = 10;
         self.contentView.layer.cornerRadius = 10;
         self.contentView.layer.masksToBounds = YES;
         self.contentView.layer.shouldRasterize = YES;
     }
     return self;
 }
 
 // 加入图片子视图
 - (void)layoutSubviews{
    [super layoutSubviews];
    _imgView.frame = self.contentView.bounds;
    [self.contentView addSubview:self.imgView];
}

// 设置大小
- (void)setFrame:(CGRect)frame {
    float margin = 10;
    frame.origin.x += margin;
    frame.origin.y += margin/2;
    frame.size.width -= 2 * margin;
    frame.size.height -= margin;
    
    [super setFrame:frame];
}

- (UIImageView *)imgView{
    if(!_imgView){
        _imgView = [[UIImageView alloc]initWithFrame:self.contentView.bounds];
        [_imgView setContentMode:UIViewContentModeScaleToFill];
    }
    return _imgView;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
@end

